package android.zhcs.myapplication;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import org.jetbrains.annotations.NotNull;

public class myrec extends RecyclerView {
    public myrec(@NonNull @NotNull Context context) {
        super(context);
    }

    public myrec(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public void setAdater(int a, final int b, final int c,Cac cal) {
        setLayoutManager(new StaggeredGridLayoutManager(a,1));
        setAdapter(new Adapter() {
            @NonNull
            @NotNull
            @Override
            public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
                View inflate = LayoutInflater.from(getContext()).inflate(c, null, false);
                return new ViewHolder(inflate) {
                };
            }

            @Override
            public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) {
cal.bix(holder.itemView,position);
            }

            @Override
            public int getItemCount() {
                return b;
            }
        });
    }

    public myrec(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
}
